#include<stdio.h>
int main(){
	int a = 0;
	int b = 0;
	int i = 0;
	int c = 0; 
	scanf("%d %d" ,&a ,&b);
	
	if(a<b){
		i = b;
		b = a;
		a = b;
		}
	c = a % b;
	while( c != 0){
		a = b;
		b = c;
		c = a % b;
	}
	printf("%d\n",b);
	return 0;	
}
 
